<?php
class IndexAction extends Action {

    public function _initialize() {
        $Config = A('Config');
        $Config->checkLogIn();
        $Config->checkUserLevel(array('1', '2', '3'));
    }
    
    public function index() {
        $Setting = M('Setting');
        $setting = $Setting->find(1);
        
        // $User = M('User');
        // $user = $User->join(array('econ_user_type ON econ_user.user_type_id = econ_user_type.user_type_id'))->find();
        
        $this->assign('site_name', $setting['site_name']);
        $this->display();
    }
    
    public function top() {
        $this->display();
    }
    
    public function center() {
        $this->display();
    }
    
    public function down() {
        $this->display();
    }
    
    public function left() {
        $this->display();
    }
    
    // 后台首页
    public function right() {
        // $this->display();
        if ($_SESSION['user']['user_type_id'] == 1) {
            load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
            $env_table = check_env();//根据当前函数获取当前环境
            echo $env_table;
        } else if ($_SESSION['user']['user_type_id'] == 2) {
            header('location:' . U('Article/index?id=11'));
        } else if ($_SESSION['user']['user_type_id'] == 3) {
            header('location:' . U('Teacher/edit?id=' . $_SESSION['user']['user_id']));
        }
    }
    
    /* 系统设置 */
    public function setting() {
        $Setting = M('setting');
        $setting = $Setting->find(1);
        
        $this->assign('setting', $setting);
        $this->display();
    }
    
    /* 保存系统设置 */
    public function saveSetting() {
        
    }

    /**
    +----------------------------------------------------------
    * 探针模式
    +----------------------------------------------------------
    */
    public function checkEnv() {
        load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
        $env_table = check_env();//根据当前函数获取当前环境
        echo $env_table;
    }
    
}
?>